package tests;

import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TestServer {
	public static void main(String args[]){
		try {
			System.out.println("creating socket in port 80...");
			ServerSocket serverSocket = new ServerSocket(80);
			System.out.println("socket created!");
			Socket socket = serverSocket.accept();
			System.out.println("accepted a client!");
			OutputStream outputStream = socket.getOutputStream();
			ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);
			System.out.println("sending message to client...");
			objectOutputStream.writeObject(new Message(54, "hello from server!"));
			System.out.println("wrote message!");
			objectOutputStream.close();
			outputStream.close();
			socket.close();
			serverSocket.close();
			System.out.println("server test done!");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
